﻿using System.Web.Mvc;

namespace WebSite.Controllers
{
    public interface ISessionConfiguration
    {
        void SetValue(Controller controller, string name, object value);
        T GetValue<T>(Controller controller, string name);
        void Abandon(Controller controller);
    }

    public class SessionConfiguration : ISessionConfiguration
    {
        public void SetValue(Controller controller, string name, object value)
        {
            controller.Session[name] = value;
        }

        public T GetValue<T>(Controller controller, string name) 
        {
            return (T) controller.Session[name];
        }

        public void Abandon(Controller controller)
        {
            controller.Session.Abandon();
        }
    }
}